package mapper;

import entity.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookMapper {

    @Select("select * from book")
    List<Book> selectAllBooks();


    @Select("select * from book where bookId =#{id}")
    Book selectBookById(int id);


    @Delete("delete from book where bookId = #{id}")
    int deleteBookById(int id);


    @Insert("insert into book (bookName ,bookAuthor,bookPublisher) values(#{bookName},#{bookAuthor},#{bookPublisher})")
    int insertBook(Book book);


    @Update("update book set bookName =#{bookName},bookAuthor=#{bookAuthor},")
    int updateBook(Book book);


    @Select("select * from book where bookName like '%${bookName}%';")
    List<Book> selectBookByBookName(String bookName);
}
